extends MarginContainer
class_name CityInfoHeroListItem

const _avatar_base_path:String = "res://Art/Human/"

#region ui引用
@onready var hero_name_label: Label = $HBoxContainer/MarginContainer/AvatarTextureRect/HeroNameLabel
@onready var hp_rich_text_label: RichTextLabel = $HBoxContainer/MarginContainer3/VBoxContainer/HBoxContainer/HPRichTextLabel
@onready var devotion_label: Label = $HBoxContainer/MarginContainer3/VBoxContainer/HBoxContainer2/DevotionLabel
@onready var level_label: Label = $HBoxContainer/MarginContainer3/VBoxContainer/HBoxContainer3/LevelLabel
@onready var wushu_label: Label = $HBoxContainer/MarginContainer2/GridContainer/HBoxContainer/WushuLabel
@onready var agility_label: Label = $HBoxContainer/MarginContainer2/GridContainer/HBoxContainer2/AgilityLabel
@onready var intelligence_label: Label = $HBoxContainer/MarginContainer2/GridContainer/HBoxContainer3/IntelligenceLabel
@onready var commandry_label: Label = $HBoxContainer/MarginContainer2/GridContainer/HBoxContainer4/CommandryLabel
@onready var morality_label: Label = $HBoxContainer/MarginContainer2/GridContainer/HBoxContainer5/MoralityLabel
@onready var beauty_label: Label = $HBoxContainer/MarginContainer2/GridContainer/HBoxContainer6/BeautyLabel
@onready var underling_label: Label = $HBoxContainer/MarginContainer4/VBoxContainer/HBoxContainer2/UnderlingLabel
@onready var exp_label: Label = $HBoxContainer/MarginContainer4/VBoxContainer/HBoxContainer3/ExpLabel
@onready var avatar_texture_rect: TextureRect = $HBoxContainer/MarginContainer/AvatarTextureRect

#endregion

var _hero_entity:HeroEntity
var hero_entity:HeroEntity:
	get:
		return _hero_entity
	set(value):
		_hero_entity = value
		_update_ui()

func _update_ui():	
	hero_name_label.text = _hero_entity.hero_name
	hp_rich_text_label.clear()
	hp_rich_text_label.text = ""
	hp_rich_text_label.text = var_to_str(floor(_hero_entity.health)) + "/" + var_to_str(floor(_hero_entity.health_max))
	devotion_label.text = var_to_str(_hero_entity.devotion)
	level_label.text = var_to_str(_hero_entity.level)
	wushu_label.text = var_to_str(_hero_entity.wushu)
	wushu_label.add_theme_color_override("font_color",Utils.get_attr_text_color(_hero_entity.wushu))
	agility_label.text = var_to_str(_hero_entity.agility)
	agility_label.add_theme_color_override("font_color",Utils.get_attr_text_color(_hero_entity.agility))
	commandry_label.text = var_to_str(_hero_entity.commandry)
	commandry_label.add_theme_color_override("font_color",Utils.get_attr_text_color(_hero_entity.commandry))
	intelligence_label.text = var_to_str(_hero_entity.intelligence)
	intelligence_label.add_theme_color_override("font_color",Utils.get_attr_text_color(_hero_entity.intelligence))
	morality_label.text = var_to_str(_hero_entity.morality)
	morality_label.add_theme_color_override("font_color",Utils.get_attr_text_color(_hero_entity.morality))
	beauty_label.text = var_to_str(_hero_entity.beauty)
	beauty_label.add_theme_color_override("font_color",Utils.get_attr_text_color(_hero_entity.beauty))
	underling_label.text = var_to_str(_hero_entity.underling_value)
	exp_label.text = var_to_str(floor(_hero_entity.exp))
	avatar_texture_rect.texture = _hero_entity.hero_avatar_texture
	pass
